//
//  OwnContactCell.m
//  ChampoinPeso
//
//  Created by mac on 2025/3/18.
//

#import "OwnContactCell.h"

@implementation OwnContactCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupUI];
    }
    return self;
}

-(void)setupUI{
    UIView *view = [UIView new];
    [self.contentView addSubview:view];
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_offset(0);
        make.left.mas_offset(13);
        make.right.mas_offset(-13);
        make.bottom.mas_offset(-20);
    }];
    view.backgroundColor = UIColor.whiteColor ;
    view.layer.cornerRadius  = 10;
    [view addSubview:self.title];
    [self.title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_offset(15);
        make.centerX.mas_equalTo(view);
    }];
    
    [view addSubview:self.titleLabel];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_title.mas_bottom).offset(18);
        make.left.mas_offset(12);
    }];
    UIView *view1 = [UIView new];
    view1.backgroundColor  = UIColor.clearColor;
    [view addSubview:view1];
    [view1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_titleLabel.mas_bottom).offset(10);
        make.left.mas_offset(KWidth(12));
        make.right.mas_offset(KWidth(-12));
        make.height.mas_equalTo(52);
    }];
    
    UIImageView *bg= [UIImageView new];
    bg.image = [UIImage imageNamed:@"textBG"];
    
    [view1 addSubview:bg];
    [bg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.mas_offset(0);
    }];
    
    [view1 addSubview:self.name];
    [_name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(10);
        make.right.mas_offset(-10);
        make.top.bottom.mas_equalTo(view1);
    }];
    
    [view1 addSubview:self.detailImg];
    [_detailImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_offset(-10);
        make.centerY.mas_equalTo(view1);
    }];
    
    
    [view addSubview:self.titleLabel2];
    [_titleLabel2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(view1.mas_bottom).offset(18);
        make.left.mas_offset(12);
    }];

    UIView *view2 = [UIView new];
    view2.backgroundColor  = UIColor.clearColor;
    [view addSubview:view2];
    [view2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_titleLabel2.mas_bottom).offset(10);
        make.left.mas_offset(KWidth(12));
        make.right.mas_offset(KWidth(-12));
        make.height.mas_equalTo(52);
        make.bottom.mas_offset(-15);
    }];
    
    UIImageView *bg2= [UIImageView new];
    bg2.image = [UIImage imageNamed:@"textBG"];
    
    [view2 addSubview:bg2];
    [bg2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.mas_offset(0);
    }];
    
    [view2 addSubview:self.name2];
    [_name2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(10);
        make.right.mas_offset(-10);
        make.top.bottom.mas_equalTo(view2);
    }];
    
    [view2 addSubview:self.detailImg2];
    [_detailImg2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_offset(-10);
        make.centerY.mas_equalTo(view2);
    }];

}

-(UILabel *)title{
    if (!_title) {
        _title = [UILabel new];
        _title.font  = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
        _title.textColor = HexColor(@"#000000");
    }
    return _title;
}

-(UITextField *)name
{
    if (!_name) {
        _name = [UITextField new];
        _name.font = [UIFont systemFontOfSize:16];
        _name.textColor = UIColor.blackColor;
    }
    return _name;
}
-(UITextField *)name2
{
    if (!_name2) {
        _name2 = [UITextField new];
        _name2.font = [UIFont systemFontOfSize:16];
        _name2.textColor = UIColor.blackColor;
    }
    return _name2;
}

-(UILabel *)titleLabel
{
    if (!_titleLabel) {
        _titleLabel = [UILabel new];
        _titleLabel.font  = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
        _titleLabel.textColor = HexColor(@"#000000");
    }
    return _titleLabel;
}

-(UILabel *)titleLabel2
{
    if (!_titleLabel2) {
        _titleLabel2 = [UILabel new];
        _titleLabel2.font  = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
        _titleLabel2.textColor = HexColor(@"#000000");
    }
    return _titleLabel2;
}


-(UIImageView *)detailImg
{
    if (!_detailImg) {
        _detailImg = [UIImageView new];
    }
    return _detailImg;
}

-(UIImageView *)detailImg2
{
    if (!_detailImg2) {
        _detailImg2 = [UIImageView new];
    }
    return _detailImg2;
}


-(void)setPlaceHolder:(NSString *)placeHolder
{
    NSDictionary *attributes = @{
        NSForegroundColorAttributeName: [UIColor lightGrayColor],
        NSFontAttributeName: [UIFont systemFontOfSize:14]
    };
    self.name.attributedPlaceholder = [[NSAttributedString alloc] initWithString:placeHolder attributes:attributes];
}
-(void)setPlaceHolder2:(NSString *)placeHolder2
{
    NSDictionary *attributes = @{
        NSForegroundColorAttributeName: [UIColor lightGrayColor],
        NSFontAttributeName: [UIFont systemFontOfSize:14]
    };
    self.name2.attributedPlaceholder = [[NSAttributedString alloc] initWithString:placeHolder2 attributes:attributes];
}
@end
